package cn.jtfadmin.codegen.domain.entity;

import cn.jtfadmin.base.data.jpa.domain.entity.BaseEntity;
import cn.jtfadmin.base.lang.common.domain.dto.EditPDTO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 代码生成类Entity
 */
@Entity
@Table(name = "code_gen_class")
@Getter
@Setter
@ToString
public class CodeGenClassEntity extends BaseEntity implements Serializable, EditPDTO {

    /**
     * 类
     */
    @Column(name = "class_name", unique = true)
    private String className;

    /**
     * 表名
     */
    @Column(name = "table_name")
    private String tableName;

    /**
     * 类描述
     */
    @Column(name = "comment")
    private String comment;

    /**
     * 父类名
     */
    @Column(name = "super_class_name")
    private String superClassName;

    /**
     * 实现接口名
     */
    @Column(name = "interface_class_names")
    @Lob
    private String interfaceClassNames;

    /**
     * 字段
     */
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "class_id")
    @OrderBy("sort")
    private List<CodeGenFieldEntity> fields;

    /**
     * url 前缀
     */
    @Column(name = "url_prefix")
    protected String urlPrefix;
}
